package com.itlong.cloud.app.resource;

import com.itlong.cloud.POJO.DTO.app.AppApplyRoomCertificationDTO;
import com.itlong.cloud.POJO.DTO.app.AppCallLiftSaveDTO;
import com.itlong.cloud.POJO.VO.MessageVO;
import com.itlong.cloud.POJO.VO.app.AppCallElevatorRecordVO;
import com.itlong.cloud.POJO.VO.app.AppElevatorFloorSimpleVO;
import com.itlong.cloud.POJO.VO.app.AppRoomApplyLogVO;
import com.itlong.cloud.app.service.IAppHomeService;
import com.itlong.cloud.user.app.IAppHomeServiceClient;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *     新版APP的首页版块接口代理实现
 * </desc>
 *
 * @createDate 2017/9/19.
 */
@RestController
public class AppHomeServiceResource implements IAppHomeServiceClient {
    @Autowired
    IAppHomeService iAppHomeService;


    /**
     * <desc>
     *      APP端_首页版块根据房间ID获取房间业主的电话号码
     * </desc>
     * @param roomId 房间ID
     * @return
     * @throws Exception
     * @createDate 2017/9/30
     * @author cuiduanwu
     */
    @Override
    @RequestMapping(path = "/home/getOwnerPhoneNumber",method = RequestMethod.POST)
    public String getOwnerPhoneNumber(@RequestParam("roomId") String roomId) throws  Exception{
        return  iAppHomeService.getOwnerPhoneNumber(roomId);
    }

    /**
     * <desc>
     *      根据房间编号获取房间类型
     * </desc>
     * @param roomId 房间ID
     * @return
     * @throws Exception
     * @createDate 2019/5/21
     * @author Qiang.S
     */
    @Override
    @RequestMapping(path = "/home/getRoomTypeByroomId",method = RequestMethod.POST)
    public String getRoomTypeByroomId(@RequestParam("roomId") String roomId) throws  Exception{
        return  iAppHomeService.getRoomTypeByroomId(roomId);
    }

    /**
     * <desc>
     *     APP端_首页版块,用户提交房屋认证申请
     * </desc>
     * @param appApplyRoomCertificationDTO 用户提交申请房屋认证数据
     * @return
     * @createDate 2017/9/30
     * @author cuiduanwu
     */
    @Override
    @RequestMapping(path = "/home/applyCertification",method = RequestMethod.POST)
    public MessageVO applyRoomCertification(@RequestBody AppApplyRoomCertificationDTO appApplyRoomCertificationDTO) throws  Exception{

        return iAppHomeService.applyRoomCertification(appApplyRoomCertificationDTO);
    }

    /**
     * <desc>
     *      获取房间申请记录。
     * <desc/>
     *
     * @param  projectId
     * @param  userId
     * @param  pageNum
     * @return
     * @author shengen.T
     * @createDate 2018-03-27
     */
    @RequestMapping(path = "/home/homeApplyLog",method = RequestMethod.POST)
    public Page<AppRoomApplyLogVO> getApplyRoomLog(@RequestParam("projectId") String projectId, @RequestParam("userId") String userId, @RequestParam("pageNum") String pageNum) throws Exception{
        return iAppHomeService.getApplyRoomLog(projectId,userId,pageNum);
    }

    /**
     * <desc>
     *      保存呼梯记录。
     * <desc/>
     *
     * @param  saveDTO
     * @return
     * @author shengen.T
     * @createDate 2018-04-02
     */
    @Override
    @RequestMapping(path = "/home/cloudCallLift",method = RequestMethod.POST)
    public Integer saveCallLiftRecord(@RequestBody AppCallLiftSaveDTO saveDTO) throws Exception{
        return iAppHomeService.saveCallLiftRecord(saveDTO);
    }

    /**
     * <desc>
     *      获取呼梯记录。
     * <desc/>
     *
     * @param  userId 用户ID
     * @param  deviceUnique 设备唯一ID
     * @return
     * @author shengen.T
     * @createDate 2018-04-03
     */
    @RequestMapping(path = "/home/liftMark",method = RequestMethod.POST)
    public List<AppCallElevatorRecordVO> getCallElevatorRecord(@RequestParam("userId") String userId, @RequestParam("deviceUnique") String deviceUnique) throws Exception{
        return iAppHomeService.getCallElevatorRecord(userId,deviceUnique);
    }

    /**
     * <desc>
     *      清除呼梯记录。
     * <desc/>
     *
     * @param  userId
     * @param  projectId
     * @param  deviceUnique
     * @return
     * @author shengen.T
     * @createDate 2018-04-04
     */
    @Override
    @RequestMapping(path = "/home/deleteLiftMark",method = RequestMethod.POST)
    public Integer deleteCallElevatorRecord(@RequestParam("userId") String userId,@RequestParam("projectId") String projectId,@RequestParam("deviceUnique") String deviceUnique) throws Exception{
        return iAppHomeService.deleteCallElevatorRecord(userId,deviceUnique,projectId);
    }

    /**
     * <desc>
     *      取消预约呼梯。
     * <desc/>
     *
     * @param  userId 用户Id
     * @param  deviceUnique 设备唯一Id
     * @param  projectId 项目编号
     * @return
     * @author shengen.T
     * @createDate 2018-04-11
     */
    @Override
    @RequestMapping(path = "/home/cancelCallLift",method = RequestMethod.POST)
    public Integer cancelCallLift(@RequestParam("userId") String userId,@RequestParam("projectId") String projectId,@RequestParam("deviceUnique") String deviceUnique) throws Exception{
        return iAppHomeService.cancelCallLift(userId,deviceUnique,projectId);
    }

    /**
     * <desc>
     *      获取真实楼层信息。
     * <desc/>
     *
     * @param deviceUnique 设备唯一编号
     * @param fromId 出发楼层ID
     * @param toId 目标楼层ID
     * @return
     * @author shengen.T
     * @createDate 2018-04-12
     */
    @Override
    @RequestMapping(path = "/home/getRealFloorInfo",method = RequestMethod.POST)
    public AppElevatorFloorSimpleVO getRealFloorInfo(@RequestParam("deviceUnique") String deviceUnique, @RequestParam("fromId") String fromId, @RequestParam("toId") String toId) throws Exception{
        return iAppHomeService.getRealFloorInfo(deviceUnique,fromId,toId);
    }

    /**
     * <desc>
     *      获取楼层权限标识
     * <desc/>
     *
     * @param deviceUnique 设备唯一编号
     * @param fromId 出发楼层名称
     * @param toId 到达楼层名称
     * @return
     * @author Jiaqi.X
     * @createDate 2018/11/29
     */
    @RequestMapping(path = "/home/getNaturalFloor",method = RequestMethod.POST)
    public Map<String,Object> getNaturalFloor(@RequestParam("deviceUnique") String deviceUnique,@RequestParam("fromId") String fromId,@RequestParam("toId") String toId) throws Exception{
        return iAppHomeService.getNaturalFloor(deviceUnique,fromId,toId);
    }

    /**
     * <desc>
     *      设备验证(梯控)。
     * <desc/>
     *
     * @param projectId 项目编号
     * @param deviceId 项目ID
     * @return
     * @author Qiang.S
     * @createDate 2018-05-14
     */
    @Override
    @RequestMapping(path = "/home/elevatorAuthorityCheck",method = RequestMethod.POST)
    public Integer elevatorAuthorityCheck(@RequestParam("projectId") String projectId,@RequestParam("deviceId") String deviceId) throws Exception{
        return iAppHomeService.elevatorAuthorityCheck(projectId,deviceId);
    }

    /**
     * <desc>
     *      设备验证(门禁)。
     * <desc/>
     *
     * @param projectId 项目编号
     * @param deviceId 项目ID
     * @return
     * @author Qiang.S
     * @createDate 2018-05-14
     */
    @Override
    @RequestMapping(path = "/home/entranceAuthorityCheck",method = RequestMethod.POST)
    public Integer entranceAuthorityCheck(@RequestParam("projectId") String projectId,@RequestParam("deviceId") String deviceId) throws Exception{
        return iAppHomeService.entranceAuthorityCheck(projectId,deviceId);
    }

    /**
     * <desc>
     *      登陆验证。
     * <desc/>
     *
     * @param ID 账号
     * @param password 密码
     * @return
     * @author Qiang.S
     * @createDate 2018-05-14
     */
    @RequestMapping(path = "/home/engineerLoginVerify",method = RequestMethod.POST)
    public Integer engineerLoginVerify(@RequestParam("ID") String ID,@RequestParam("password") String password) throws Exception{
        return iAppHomeService.engineerLoginVerify(ID,password);
    }

    /**
     * <desc>
     *      批量获取真实楼层信息。
     * <desc/>
     *
     * @param deviceUnique 设备唯一编号
     * @param floorString 楼层端子号列表,多个逗号隔开
     * @return
     * @author shengen.T
     * @createDate 2018-05-18
     */
    @Override
    @RequestMapping(path = "/home/batchGetRealFloorList",method = RequestMethod.POST)
    public String batchGetRealFloorList(@RequestParam("deviceUnique") String deviceUnique,@RequestParam("floorString") String floorString) throws Exception{
        return iAppHomeService.batchGetRealFloorList(deviceUnique,floorString);
    }

    /**
     * <desc>
     *      检测用户是否在项目下。
     * <desc/>
     *
     * @param userId 用户编号
     * @param projectId 项目编号
     * @return
     * @author shengen.T
     * @createDate 2018-05-29
     */
    @Override
    @RequestMapping(path = "/home/checkUserInProject",method = RequestMethod.POST)
    public Map<String,Object> checkUserInProject(@RequestParam("userId") String userId, @RequestParam("projectId") String projectId){
        return iAppHomeService.checkUserInProject(userId,projectId);
    }

    /**
     * <desc>
     *      根据人脸获取访客名称。
     * <desc/>
     *
     * @param userId 用户编号
     * @param projectId 项目编号
     * @return
     * @author Qiang.S
     * @createDate 2019-05-16
     */
    @Override
    @RequestMapping(path = "/home/getVisitorName",method = RequestMethod.POST)
    public String getVisitorName(@RequestParam("userId") String userId, @RequestParam("projectId") String projectId){
        return iAppHomeService.getVisitorName(userId,projectId);
    }


}
